package com.tjhk.netty.test.handlers;

import com.tjhk.netty.mapping.annotation.Mapping;
import com.tjhk.netty.mapping.annotation.HandlerMapper;
import com.tjhk.netty.test.model.MyMessage;
import io.netty.channel.Channel;

@HandlerMapper
public class MyEndpoint {

    @Mapping(types = 1, desc = "注册1")
    public MyMessage register(MyMessage msg, Channel channel) {
        System.out.println("进入映射器1,channelId="+channel.id().asShortText());
        System.out.println(msg);;
        return msg;
    }
    @Mapping(types = 2, desc = "注册2")
    public void register2(MyMessage msg, Channel channel) {
        System.out.println("进入映射器2");
        MyMessage message = new MyMessage();
        message.setBody("映射器2"+msg.getBody());
        channel.close();
//        return message;
    }
//    @Mapping(types = 1, desc = "注册2")
//    public void register2(Message msg, Channel channel) {
//        System.out.println(msg+channel.id().asShortText());
//    }
}
